package com.ruoyi.generator.service;

import com.ruoyi.generator.domain.ReportSource;
import com.ruoyi.generator.util.WordUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.Date;
import java.util.List;

/**
 * 业务 服务层实现
 * 
 * @author ruoyi
 */
@Service
public class GenWordServiceImpl implements IGenWordService
{
    private static final Logger log = LoggerFactory.getLogger(GenWordServiceImpl.class);
    @Value("${ruoyi.profile}")
    private  String ruoyiProfile;

    @Value("${phantomjs.defaultHeadImage}")
    private String headImagePath;

    @Override
    public String genWord(List<ReportSource> contents, String reportName, String getFontFamily, String fontFamilyTitle, String fontFamilyTitleSecond, String fontWeight, String fontWeightTitle, String fontWeightTitleSecond, String publishingDepartment, Integer fontSizeTitle, Integer fontSizeParagraph, Integer fontSizeContent, String eventTitle, String fontTitleColor, String style, Date startTime, Date endTime) {

        try {
            return WordUtils.getExcelWithTitle(headImagePath,ruoyiProfile,contents,reportName,getFontFamily,fontFamilyTitle,fontFamilyTitleSecond,fontWeight,fontWeightTitle,fontWeightTitleSecond,publishingDepartment,fontSizeTitle,fontSizeParagraph,fontSizeContent,eventTitle,fontTitleColor,style,startTime,endTime);
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
}